package com.android.hq.ganktoutiao.ui.fragment;

import com.android.hq.ganktoutiao.data.GanNewsItem;
import com.android.hq.ganktoutiao.data.GankItem;
import com.android.hq.ganktoutiao.data.JingJiItem;
import com.android.hq.ganktoutiao.data.bean.JingJiResponse;
import com.android.hq.ganktoutiao.network.CallBack;
import com.android.hq.ganktoutiao.network.RequestManager;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/5/5.
 */
public class GanJingJiFragment extends BaseFragment {
    @Override
    public void updateData() {

        RequestManager.getInstance().getDayJingJi(new CallBack<JingJiResponse>() {
            @Override
            public void onSuccess(JingJiResponse jingJiResponse) {
                mRefreshLayout.setRefreshing(false);
                ArrayList<GankItem> list  = new ArrayList<GankItem>();
                JingJiItem jingJiItem = jingJiResponse.t;
                List<JingJiItem> list1 = jingJiItem.news;
                list.addAll(list1);
                mAdapter.updateData(list);
                updateSuccess(list.isEmpty());
            }

            @Override
            public void onFail() {
                mRefreshLayout.setRefreshing(false);
                updateError();

            }
        });

    }

    @Override
    public void loadMore() {

    }

    @Override
    public boolean isEnablePullRefresh() {
        return true;
    }

    @Override
    public boolean isEnableLoadingMore() {
        return true;
    }

    @Override
    public boolean isEnableRefreshOnViewCreate() {
        return true;
    }
}
